<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2015/3/2
  Time: 15:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<style>
th{font-weight:500}
</style>
<div class="row" style="padding:2px;margin-bottom: 5px ">
    <div class="col-sm-12 col-md-12 col-lg-12">
        <div >
            <%--<form id="searchForm" method="post" action="">--%>
                <%--<a id="ajax_proback_btn_add" class="btn btn-default " data-toggle="modal"><i class="fa fa-lg fa-plus"></i> 新建项目反馈表</a>--%>
            <%--</form>--%>
        </div>
    </div>
</div>
<table class="table table-bordered col-md-12 col-lg-12" style="margin-bottom:5px">
    <tbody>
    <tr>
        <th  class="col-lg-1 col-md-1 text-justify" style="line-height: 40px;">按项目查询</th>
        <td class="col-lg-2 col-md-2">
            <select class="select2 col-md-5" id="ajax_map_project_selected">
                <optgroup label="支持过滤查询">
                    <option value="">请选择...</option>
                    <s:iterator value="proInfoList" id="list">
                        <option value="<s:property value="#list.id"/>"><s:property value="#list.name"/></option>
                    </s:iterator>
                </optgroup>
            </select>
        </td>
        <th class="col-lg-1 col-md-1 text-justify" style="line-height: 40px;">按反馈类别查询</th>
        <td class="col-lg-2 col-md-2">
            <select class="select2 col-md-5" id="ajax_proback_type_selected">
                <optgroup label="支持过滤查询">
                    <option value="">请选择...</option>
                    <s:iterator value="probackType" id="list">
                        <option value="<s:property value="#list.id"/>"><s:property value="#list.name"/></option>
                    </s:iterator>
                </optgroup>
            </select>
        </td>
        <th class="col-lg-1 col-md-1 text-justify" style="line-height: 40px;">日期筛选</th>
        <td class="col-lg-3 col-md-3">
            <label class="input" style="vertical-align:0px"> <i class="icon-prepend fa fa-calendar fa-lg"></i>
                <input class="hasDatepicker" style="height:34px;padding-left:10px;margin-left:3px" type="text"  id="start" placeholder="起始日期">
            </label>
            <label class="input" style="padding-left:18px;vertical-align:0px"> <i class="icon-prepend fa fa-calendar fa-lg"></i>
                <input class="hasDatepicker" style="height:34px;padding-left:10px;margin-left:3px" type="text"  id="end" placeholder="截止日期">
            </label>
        </td>
        <td class="col-lg-2 col-md-2">
            <span id="loading" style="display:none;font-size:14px;color:#03a9f4"><img src="../resource/com/img/loading-icon.gif" width="20" height="20"/>&nbsp;正在进行下载，请稍候...</span>
            <a id="ajax_export_proBack_datas" class="btn btn-default btn-primary pull-left" href="javascript:void(0)"> 反馈信息数据导出 <i class="fa fa-lg fa-external-link"></i></a>
        </td>
    </tr>
    </tbody>
</table>
<section id="widget-grid" class="">
    <!-- row -->
    <div class="row">
        <!-- NEW WIDGET START -->
        <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <!-- Widget ID (each widget will need unique ID)-->
            <div class="jarviswidget " id="wid-id-0" data-widget-editbutton="false"
                 data-widget-colorbutton="false"
                 data-widget-togglebutton="false"
                 data-widget-deletebutton="false"
                 data-widget-fullscreenbutton="true"
                 data-widget-custombutton="false"
                 data-widget-sortable="false">

                <!-- widget div-->
                <div>
                    <!-- widget edit box -->
                    <div class="jarviswidget-editbox">
                        <!-- This area used as dropdown edit box -->
                    </div>
                    <!-- end widget edit box -->

                    <!-- widget content -->
                    <div class="widget-body no-padding">
                        <div class="col-sm-12 col-md-12 col-lg-12">
                            <div class=" ">
                                <div class="row" id="ajax_proback_list_row">
                                    <table id="ajax_proback_table" class="table table-striped table-bordered table-hover">
                                    </table>
                                    <div id="ajax_proback_list_page">
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                    <!-- end widget content -->

                </div>
                <!-- end widget div -->
            </div>
            <!-- end widget -->
        </article>

        <!-- WIDGET END -->
    </div>
    <!-- end row -->
</section>

<script type="text/javascript">
    // DO NOT REMOVE : GLOBAL FUNCTIONS!
    pageSetUp();

    function proback_reload(){
        loadURL("ajax-pro-back!view.action",$('div#main div#business_data'));
    }
    $("#ajax_proback_btn_add").click(function(){
        loadURL("ajax-pro-back!input.action",$('div#main div#business_data'));
    });

</script>
<script type="text/javascript">

    $(function(){
        $("#start").datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            todayBtn: 'linked',
            language: 'zh-CN'
        }).on('changeDate',function(ev){
            var startTime = ev.date.valueOf();
            start = startTime;
        });
        $('#end').datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            todayBtn: 'linked',
            language: 'zh-CN'
        }).on('changeDate',function(ev){
            var endTime = ev.date.valueOf();
            end = endTime;
        });

        $('#ajax_export_proBack_datas').click(function(){
            var proInfoId = $("#ajax_map_project_selected").val();
            var content = "";
            if(proInfoId != ""){
                content = "您确定要导出所选项目的所有反馈数据吗？";
            }else{
                content = "您确定要导出所有项目的所有反馈数据吗？";
            }
            $.tzDialog({title:"确定提示",content:content,callback:function(ok){
                if(ok){
                   //$('#loading').show();
                   //$('#ajax_export_proBack_datas').hide();
                    $('#data_loading').show();
                   $.ajax({
                           type : "POST",
                           url : "ajax-pro-back!exportAllData.action",
                           dataType : 'json',
                           data : {"proInfoId":proInfoId},
                           cache : false,
                           async:true,
                           success:function(data){
                                 if(data.state == "200"){
                                    location.href = "ajax-pro-back!download.action?now="+data.message ;
                                 }else{
                                      alert("您没有反馈信息");
                                 }
                                 //$('#loading').hide();
                                 //$('#ajax_export_proBack_datas').show();
                               $('#data_loading').hide();
                           }
                   });
                } else {

                }
            }});

        });

    });

    $('.hasDatepicker').datetimepicker({
        format: 'yyyy-mm-dd',
        weekStart: 1,
        autoclose: true,
        todayBtn: 'linked',
        language: 'zh-CN',
        minView:2
    });
    $("#ajax_map_project_selected").change(function(){
        var data = {proInfoId:$("#ajax_map_project_selected").val(),probackTypeId:$("#ajax_proback_type_selected").val(),start:$("#start").val(),end:$("#end").val()};
        $("#ajax_proback_table").jqGrid("setGridParam",{
            datatype:"json",
            postData:data
        }).trigger("reloadGrid");
    });

    $("#ajax_proback_type_selected").change(function(){
        var data = {proInfoId:$("#ajax_map_project_selected").val(),probackTypeId:$("#ajax_proback_type_selected").val(),start:$("#start").val(),end:$("#end").val()};
        $("#ajax_proback_table").jqGrid("setGridParam",{
            datatype:"json",
            postData:data
        }).trigger("reloadGrid");
    });

    $("#start").change(function(){
        var data = {proInfoId:$("#ajax_map_project_selected").val(),probackTypeId:$("#ajax_proback_type_selected").val(),start:$("#start").val(),end:$("#end").val()};
        $("#ajax_proback_table").jqGrid("setGridParam",{
            datatype:"json",
            postData:data
        }).trigger("reloadGrid");
    });
    $("#end").change(function(){
        var data = {proInfoId:$("#ajax_map_project_selected").val(),probackTypeId:$("#ajax_proback_type_selected").val(),start:$("#start").val(),end:$("#end").val()};
        $("#ajax_proback_table").jqGrid("setGridParam",{
            datatype:"json",
            postData:data
        }).trigger("reloadGrid");
    });

    $(function(){
        load_proback_jqGrid();
    });
    function load_proback_jqGrid(){
        jQuery("#ajax_proback_table").jqGrid({
            url:'ajax-pro-back!list.action',
            datatype: "json",
            colNames:['项目名称',"反馈日期",'反馈类别',"反馈内容","反馈人","是否正常","通知人员","操作","id"],
            colModel:[
                {name:'proname',index:'proInfo', width:120,sortable:true,search:true,
                    searchoptions:{sopt: ["cn"],clearSearch:true}},
                {name:'backDate',index:'backDate', width:80,search:false,
                    searchoptions:{sopt: ["cn"],clearSearch:true}},
                {name:'category',index:'category', width:80,search:true,
                    searchoptions:{sopt: ["cn"],clearSearch:true}},
                {name:'content',index:'content', width:180,search:false},
                {name:'creater',index:'creater', width:80,search:true,
                    searchoptions:{sopt: ["cn"],clearSearch:true}},
                {name:'regular',index:'regular', width:80,search:false,
                    searchoptions:{sopt: ["cn"],clearSearch:true}},
                {name:'notice',index:'notice', width:180,search:false},
                {name:'act',index:'act', width:100,sortable:false,fixed:true,search:false},
                {name:'id',index:'id',hidden:true,search:false},
            ],
            rowNum : 10,
            rowList:[10,20,30],
            pager : '#ajax_proback_list_page',
            sortname : 'createDate',
            sortorder : "desc",
            gridComplete:function(){
                var ids=$("#ajax_proback_table").jqGrid('getDataIDs');
                for(var i=0;i<ids.length;i++){
                    var cl=ids[i];
                    var rowData = $("#ajax_project_table").jqGrid("getRowData",cl);
                    var de="<button class='btn btn-default' data-original-title='查看' onclick=\"fn_proback_read('"+cl+"');\"><i class='fa fa-eye'></i>查看</button>"+" ";
                    jQuery("#ajax_proback_table").jqGrid('setRowData',ids[i],{act:de});
                }
                $(".ui-jqgrid-bdiv").css("overflow-x","hidden");
                jqGridStyle();
            },
            jsonReader: {
                root: "dataRows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems : false
            },
            caption : "<i class='fa fa-arrow-circle-right'></i> 反馈信息列表",
            multiselect : false,
            rownumbers:true,
            gridview:true,
            shrinkToFit:true,
            viewrecords: true,
            autowidth: true,
            height:'auto',
            forceFit:true,
            loadComplete: function() {
            }
        });
        $(window).on('resize.jqGrid', function() {
            jQuery("#ajax_proback_table").jqGrid('setGridWidth', $("#ajax_proback_list_row").width());
        })
        jQuery("#ajax_proback_table").jqGrid('filterToolbar',{searchOperators:false,stringResult:true});
        jQuery("#ajax_proback_table").jqGrid('navGrid', "#ajax_proback_list_page", {
            edit : false,
            add : false,
            del : false,
            search:false
        });
    };

    function fn_proback_read(id){
        loadURL("ajax-pro-back!read.action?keyId="+id,$('div#business_data'));
    }
</script>